<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
</head>
<style>
    html,
    body {
        background-color: #fff;
    }

    .placeholder_div {
        background-color: #fbf9f9;
    }

    input {
        font-size: 0.7rem;
        width: 90%;
        margin: 0.5rem 5% 0 5%;
        border-bottom: 1px solid #ececec;
        height: 2rem;
        outline: none;
    }

    .beizhu {
        font-size: 0.6rem;
        color: #838383;
        margin: 0.5rem 0 0.5rem 5%;
    }

    textarea {
        width: 90%;
        height: 5rem;
        margin: 0 5%;
    }

    .queren {
        width: 100%;
        height: 2.2rem;
        color: #fff;
        text-align: center;
        line-height: 2.2rem;
        font-size: 0.8rem;
        background-color: #FD6151;
        position: fixed;
        bottom: 0;
        left: 0;
    }
</style>

<body>
    <div  id="app" v-cloak>
        <div class="placeholder_div"></div>
        <input type="text" v-model="name" placeholder="医案夹名称(必填)">
        <p class="beizhu">备注</p>
        <textarea v-model="remark" placeholder="请输入医案夹备注"></textarea>

        <div class="queren" onclick="submit()">确认</div>
    </div>
</body>

</html>
<script src="../script/set_root.js"></script>

<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/zepto.min.js"></script>
<script type="text/javascript" src="../script/hb.js"></script>
<script type="text/javascript" src="../script/vue.js"></script>
<script type="text/javascript">
    apiready = function () {
        hb_ready();
    }
    //使用vue对数据进行绑定
    var app = new Vue({
        el: '#app',
        data: {
            name: "", // 医案夹名称
            remark: "", // 备注
        },
        methods: {

        },

    })

    function submit() {
        if (app.name == '' || app.name == ' ') {
            toast("请输入医案夹名称")
        } else if (app.remark == '' || app.remark == ' ') {
            toast("请输入医案夹备注")
        } else {
            post_ajax("medicalfolder/save", {
                userId: 1,
                name: app.name,
                remark: app.remark,
            }, function (res, err) {
                if (res.code == 200) {
                    toast("提交成功")
                    setTimeout(function () {
                        api.closeWin()
                    }, 500);
                    // alert(JSON.stringify(res))
                } else {
                    alert("网络不通畅，请稍后再试！")
                }

                // if (res.code == 200) {
                //     toast(JSON.stringify(res.msg))

                //     api.sendEvent({
                //         name: 'baocun_yian',
                //     });

                //     setTimeout(function () {
                //         api.closeWin()
                //     }, 500);
                // }
            })
        }

    }
</script>